package cn.faster.config.security.shiro;

import cn.faster.common.utils.sys.Encrypt;
import cn.faster.sys.entity.SysUser;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * @author xiaoCoder
 * @version 1.0
 * @description: TODO 生成用户 token 工具类
 * @date 2021/8/15 13:07
 */
@Component
public class TokenUtils {

    // 加密用户信息 用户名+id,加密的信息为 用户名+id+UUID
    public static String createUserToken(SysUser sysUser){
       return Encrypt.md5AndSha(getUserTokenKey(sysUser) + UUID.randomUUID().toString());
    }

    public static String getUserTokenKey(SysUser sysUser){
        return sysUser.getUsername() + sysUser.getId();
    }

}
